var express = require('express');
var app = express();

exports.verify=function(req,res,next){	
	console.log("verify");
	var secretKey=exports.getResult(req.query.secretKey,"");
	if(secretKey!="" && secretKey=="shisanshao@cc.com"){ 		
		next();
	}
	else{
      return res.json({ ResultCode: false,ResultMessage:'secretKey_required',MetaData:{} }); 
	}
}


exports.getResult = function (obj,defautValue) {
	var result=obj;
	if(obj==undefined||obj==null){ 
	  return defautValue;	
	}else return result;
};


/*type:md5,md4,sha1*/
exports.encrypt = function (pwd,type) {
	var crypto = require('crypto');  
	var r = crypto.createHash(type);//定义加密方式:md5不可逆,此处的md5可以换成任意hash加密的方法名称；
    r.update(pwd);
    return r.digest('hex');    
};

